package com.zxw.文件.图片;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Scalar;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

public class Image {

    public static void main(String[] args) {
        String inputImagePath = "C:\\Users\\Administrator\\Desktop\\a\\b.png";
        String outputImagePath = "C:\\Users\\Administrator\\Desktop\\a\\output.jpg";

        Mat image = Imgcodecs.imread(inputImagePath);

        // 定义水印区域的位置和大小
        int startX = 100;
        int startY = 100;
        int width = 200;
        int height = 100;

        // 使用均值模糊来覆盖水印
        Mat regionOfInterest = image.submat(startY, startY + height, startX, startX + width);
        Imgproc.rectangle(image, new org.opencv.core.Point(startX, startY), new org.opencv.core.Point(startX + width, startY + height), new Scalar(255, 255, 255), -1); // 填充白色矩形
        Imgproc.GaussianBlur(regionOfInterest, regionOfInterest, new org.opencv.core.Size(55, 55), 0); // 进行高斯模糊

        Imgcodecs.imwrite(outputImagePath, image);
    }
}
